package com.kzj.global.threadLocal;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.kzj.domain.vo.UserLoginVO;

public class UserThreadLocal {
    static ThreadLocal<UserLoginVO> user=new ThreadLocal<>();

    public static String getType()
    {
        return user.get().getType();
    }
    public static void setUser(UserLoginVO userInfo)
    {
        user.set(userInfo);
    }
    public static Object getObj()
    {
        return user.get().getObj();
    }
//    public static<T> T getUser()
//    {
//        Object obj=getObj();
//        Class<T> aClass = (Class<T>) obj.getClass();
//        return aClass.cast(obj);
//    }
    public static <T> T getUser(Class<T> aClass)
    {
        JSONObject obj=(JSONObject)getObj();
        System.out.println(obj);
        T user = obj.toJavaObject(aClass);
        return user;
    }
}
